﻿Imports System
Imports System.Drawing
Imports System.Runtime.InteropServices
Imports System.Workflow.ComponentModel
Imports System.Workflow.ComponentModel.Design

Namespace System.Workflow.Activities
    <ComVisible(False), ActivityDesignerTheme(GetType(StateMachineWorkflowDesignerTheme))> _
    Friend NotInheritable Class StateMachineWorkflowDesigner
        Inherits StateDesigner
        ' Methods
        Protected Overrides Sub Initialize(ByVal activity As Activity)
            MyBase.Initialize(activity)
            Me.text = DR.GetString("EventBasedWorkFlow")
        End Sub

        Protected Overrides Function IsSupportedActivityType(ByVal activityType As Type) As Boolean
            If GetType(ListenActivity).IsAssignableFrom(activityType) Then
                Return False
            End If
            Return MyBase.IsSupportedActivityType(activityType)
        End Function


        ' Properties
        Friend Overrides ReadOnly Property HelpText As String
            Get
                If (Me.helpText Is Nothing) Then
                    Me.helpText = DR.GetString("StateMachineWorkflowHelpText")
                End If
                Return Me.helpText
            End Get
        End Property

        Public Overrides ReadOnly Property MinimumSize As Size
            Get
                Dim minimumSize As Size = MyBase.MinimumSize
                minimumSize.Width = Math.Max(minimumSize.Width, StateMachineWorkflowDesigner.MinSize.Width)
                minimumSize.Height = Math.Max(minimumSize.Height, StateMachineWorkflowDesigner.MinSize.Height)
                If (MyBase.IsRootDesigner AndAlso (Me.InvokingDesigner Is Nothing)) Then
                    minimumSize.Width = Math.Max(minimumSize.Width, (MyBase.ParentView.ViewPortSize.Width - (StateDesigner.Separator.Width * 2)))
                    minimumSize.Height = Math.Max(minimumSize.Height, (MyBase.ParentView.ViewPortSize.Height - (StateDesigner.Separator.Height * 2)))
                End If
                Return minimumSize
            End Get
        End Property

        Public Overrides ReadOnly Property [Text] As String
            Get
                Return Me.text
            End Get
        End Property


        ' Fields
        Private helpText As String
        Private Shared ReadOnly MinSize As Size = New Size(240, 240)
        Private [text] As String
    End Class
End Namespace

